local OnEnter = function (self)
	if InCombatLockdown() then return end
	UnitFrame_OnEnter(self)
end

local OnLeave = function (self)
	UnitFrame_OnLeave(self)
end

local ShowMenu = function (self)
	ToggleDropDownMenu(1, nil, self.menu, "cursor", 0, 0)
end

local powercolor
do
	local colors = oUF.colors.power
	powercolor = function(unit)
		local type, token = UnitPowerType(unit)
		return colors[token] or colors[type] or colors.MANA
	end
end

local core = {
	backdrop = {
		bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
		insets = {left = -1.5, right = -1.5, top = -1.5, bottom = -1.5},
	},
	statusbartexture = "Interface\\AddOns\\oUF_Jerry\\media\\statusbar",

	powercolor = powercolor,
	gray = { r = 0.5, g = 0.5, b = 0.5 },
	white = { r = 1, g = 1, b = 1 },
	unknown = { r = .41, g = .95, b = .2 },
	green = { r = 0, g = 1, b = 0 },

	classificationFormats = {
		["worldboss"] = " Boss",
		["rareelite"] = "%d+ Rare",
		["elite"] = "%d+",
		["rare"] = "%d Rare",
	},

	getDifficultyColor = function (level)
		local levelDiff = level - UnitLevel("player")
		if levelDiff >= 5 or level == -1 then
			return 1.00, 0.10, 0.10
		elseif levelDiff >= 3 then
			return 1.00, 0.50,0.25
		elseif levelDiff >= -2 then
			return 1.0, 1.0, 0.0
		elseif -levelDiff <= GetQuestGreenRange() then
			return 0.25, 0.75, 0.25
		end
		return 0.50, 0.50, 0.50
	end,

	auraIcon = function (self, button, icons, index, debuff)
		button.icon:SetTexCoord(.07, .93, .07, .93)
		if debuff then
			local overlay = button.overlay
			overlay:SetTexture("Interface\\AddOns\\oUF_Jerry\\media\\border")
			overlay:SetTexCoord(0, 1, 0, 1)
		end
	end,

	getFontString = function (parent)
		local fs = parent:CreateFontString(nil, "OVERLAY")
		fs:SetFont("Interface\\AddOns\\oUF_Jerry\\media\\barframes.ttf", 11)
		fs:SetShadowColor(0,0,0)
		fs:SetShadowOffset(0.8, -0.8)
		fs:SetTextColor(1,1,1)
		fs:SetJustifyH("LEFT")
		return fs
	end,

	styleClicks = function (self, menu)
		self:RegisterForClicks("anyup")
		self:SetScript("OnEnter", OnEnter)
		self:SetScript("OnLeave", OnLeave)
		if menu then
			self.menu = menu
			self.showmenu = ShowMenu
			self:SetAttribute("*type2", "showmenu")
		end
	end,

	styleCombatFeedback = function (parent)
		local fs = parent.Health:CreateFontString(nil, "OVERLAY")
		fs:SetFont("Interface\\AddOns\\oUF_Jerry\\media\\barframes.ttf", 16, "OUTLINE")
		fs:SetShadowColor(0,0,0)
		fs:SetShadowOffset(0.8, -0.8)
		fs:SetTextColor(1,1,1)
		fs:SetJustifyH("CENTER")
		fs:SetJustifyV("MIDDLE")
		fs:SetPoint("CENTER", parent, "CENTER")
		parent.CombatFeedbackText = fs
	end,
}

-- fix rogue color

oUF.Jerry = core
